Optimal. Leaf size=189 \[ \frac {1}{8} \left (4 a^2 A+3 A b^2+6 a b B\right ) x+\frac {\left (4 b^2 B+5 a (2 A b+a B)\right ) \sin (c+d x)}{5 d}+\frac {\left (4 a^2 A+3 A b^2+6 a b B\right ) \cos (c+d x) \sin (c+d x)}{8 d}+\frac {b (5 A b+6 a B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {b B \cos ^3(c+d x) (a+b \cos (c+d x)) \sin (c+d x)}{5 d}-\frac {\left (4 b^2 B+5 a (2 A b+a B)\right ) \sin ^3(c+d x)}{15 d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.20, antiderivative size = 189, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 6, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.194, Rules used = {3069, 3102,
2827, 2715, 8, 2713} \begin {gather*} \frac {\left (4 a^2 A+6 a b B+3 A b^2\right ) \sin (c+d x) \cos (c+d x)}{8 d}+\frac {1}{8} x \left (4 a^2 A+6 a b B+3 A b^2\right )-\frac {\left (5 a (a B+2 A b)+4 b^2 B\right ) \sin ^3(c+d x)}{15 d}+\frac {\left (5 a (a B+2 A b)+4 b^2 B\right ) \sin (c+d x)}{5 d}+\frac {b (6 a B+5 A b) \sin (c+d x) \cos ^3(c+d x)}{20 d}+\frac {b B \sin (c+d x) \cos ^3(c+d x) (a+b \cos (c+d x))}{5 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 8
Rule 2713
Rule 2715
Rule 2827
Rule 3069
Rule 3102
Rubi steps
\begin {align*} \int \cos ^2(c+d x) (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \, dx &=\frac {b B \cos ^3(c+d x) (a+b \cos (c+d x)) \sin (c+d x)}{5 d}+\frac {1}{5} \int \cos ^2(c+d x) \left (a (5 a A+3 b B)+\left (4 b^2 B+5 a (2 A b+a B)\right ) \cos (c+d x)+b (5 A b+6 a B) \cos ^2(c+d x)\right ) \, dx\\ &=\frac {b (5 A b+6 a B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {b B \cos ^3(c+d x) (a+b \cos (c+d x)) \sin (c+d x)}{5 d}+\frac {1}{20} \int \cos ^2(c+d x) \left (5 \left (4 a^2 A+3 A b^2+6 a b B\right )+4 \left (4 b^2 B+5 a (2 A b+a B)\right ) \cos (c+d x)\right ) \, dx\\ &=\frac {b (5 A b+6 a B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {b B \cos ^3(c+d x) (a+b \cos (c+d x)) \sin (c+d x)}{5 d}+\frac {1}{4} \left (4 a^2 A+3 A b^2+6 a b B\right ) \int \cos ^2(c+d x) \, dx+\frac {1}{5} \left (4 b^2 B+5 a (2 A b+a B)\right ) \int \cos ^3(c+d x) \, dx\\ &=\frac {\left (4 a^2 A+3 A b^2+6 a b B\right ) \cos (c+d x) \sin (c+d x)}{8 d}+\frac {b (5 A b+6 a B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {b B \cos ^3(c+d x) (a+b \cos (c+d x)) \sin (c+d x)}{5 d}+\frac {1}{8} \left (4 a^2 A+3 A b^2+6 a b B\right ) \int 1 \, dx-\frac {\left (4 b^2 B+5 a (2 A b+a B)\right ) \text {Subst}\left (\int \left (1-x^2\right ) \, dx,x,-\sin (c+d x)\right )}{5 d}\\ &=\frac {1}{8} \left (4 a^2 A+3 A b^2+6 a b B\right ) x+\frac {\left (4 b^2 B+5 a (2 A b+a B)\right ) \sin (c+d x)}{5 d}+\frac {\left (4 a^2 A+3 A b^2+6 a b B\right ) \cos (c+d x) \sin (c+d x)}{8 d}+\frac {b (5 A b+6 a B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {b B \cos ^3(c+d x) (a+b \cos (c+d x)) \sin (c+d x)}{5 d}-\frac {\left (4 b^2 B+5 a (2 A b+a B)\right ) \sin ^3(c+d x)}{15 d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.52, size = 146, normalized size = 0.77 \begin {gather*} \frac {60 \left (4 a^2 A+3 A b^2+6 a b B\right ) (c+d x)+60 \left (12 a A b+6 a^2 B+5 b^2 B\right ) \sin (c+d x)+120 \left (a^2 A+A b^2+2 a b B\right ) \sin (2 (c+d x))+10 \left (8 a A b+4 a^2 B+5 b^2 B\right ) \sin (3 (c+d x))+15 b (A b+2 a B) \sin (4 (c+d x))+6 b^2 B \sin (5 (c+d x))}{480 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.17, size = 184, normalized size = 0.97
method | result | size |
derivativedivides | \(\frac {a^{2} A \left (\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )+\frac {B \,a^{2} \left (\cos ^{2}\left (d x +c \right )+2\right ) \sin \left (d x +c \right )}{3}+\frac {2 A a b \left (\cos ^{2}\left (d x +c \right )+2\right ) \sin \left (d x +c \right )}{3}+2 B a b \left (\frac {\left (\cos ^{3}\left (d x +c \right )+\frac {3 \cos \left (d x +c \right )}{2}\right ) \sin \left (d x +c \right )}{4}+\frac {3 d x}{8}+\frac {3 c}{8}\right )+A \,b^{2} \left (\frac {\left (\cos ^{3}\left (d x +c \right )+\frac {3 \cos \left (d x +c \right )}{2}\right ) \sin \left (d x +c \right )}{4}+\frac {3 d x}{8}+\frac {3 c}{8}\right )+\frac {B \,b^{2} \left (\frac {8}{3}+\cos ^{4}\left (d x +c \right )+\frac {4 \left (\cos ^{2}\left (d x +c \right )\right )}{3}\right ) \sin \left (d x +c \right )}{5}}{d}\) | \(184\) |
default | \(\frac {a^{2} A \left (\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )+\frac {B \,a^{2} \left (\cos ^{2}\left (d x +c \right )+2\right ) \sin \left (d x +c \right )}{3}+\frac {2 A a b \left (\cos ^{2}\left (d x +c \right )+2\right ) \sin \left (d x +c \right )}{3}+2 B a b \left (\frac {\left (\cos ^{3}\left (d x +c \right )+\frac {3 \cos \left (d x +c \right )}{2}\right ) \sin \left (d x +c \right )}{4}+\frac {3 d x}{8}+\frac {3 c}{8}\right )+A \,b^{2} \left (\frac {\left (\cos ^{3}\left (d x +c \right )+\frac {3 \cos \left (d x +c \right )}{2}\right ) \sin \left (d x +c \right )}{4}+\frac {3 d x}{8}+\frac {3 c}{8}\right )+\frac {B \,b^{2} \left (\frac {8}{3}+\cos ^{4}\left (d x +c \right )+\frac {4 \left (\cos ^{2}\left (d x +c \right )\right )}{3}\right ) \sin \left (d x +c \right )}{5}}{d}\) | \(184\) |
risch | \(\frac {a^{2} x A}{2}+\frac {3 x A \,b^{2}}{8}+\frac {3 x B a b}{4}+\frac {3 \sin \left (d x +c \right ) A a b}{2 d}+\frac {3 \sin \left (d x +c \right ) B \,a^{2}}{4 d}+\frac {5 b^{2} B \sin \left (d x +c \right )}{8 d}+\frac {B \,b^{2} \sin \left (5 d x +5 c \right )}{80 d}+\frac {\sin \left (4 d x +4 c \right ) A \,b^{2}}{32 d}+\frac {\sin \left (4 d x +4 c \right ) B a b}{16 d}+\frac {\sin \left (3 d x +3 c \right ) A a b}{6 d}+\frac {\sin \left (3 d x +3 c \right ) B \,a^{2}}{12 d}+\frac {5 \sin \left (3 d x +3 c \right ) B \,b^{2}}{48 d}+\frac {\sin \left (2 d x +2 c \right ) a^{2} A}{4 d}+\frac {\sin \left (2 d x +2 c \right ) A \,b^{2}}{4 d}+\frac {\sin \left (2 d x +2 c \right ) B a b}{2 d}\) | \(225\) |
norman | \(\frac {\left (\frac {1}{2} a^{2} A +\frac {3}{8} A \,b^{2}+\frac {3}{4} B a b \right ) x +\left (5 a^{2} A +\frac {15}{4} A \,b^{2}+\frac {15}{2} B a b \right ) x \left (\tan ^{4}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (5 a^{2} A +\frac {15}{4} A \,b^{2}+\frac {15}{2} B a b \right ) x \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (\frac {1}{2} a^{2} A +\frac {3}{8} A \,b^{2}+\frac {3}{4} B a b \right ) x \left (\tan ^{10}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (\frac {5}{2} a^{2} A +\frac {15}{8} A \,b^{2}+\frac {15}{4} B a b \right ) x \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (\frac {5}{2} a^{2} A +\frac {15}{8} A \,b^{2}+\frac {15}{4} B a b \right ) x \left (\tan ^{8}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\frac {4 \left (50 A a b +25 B \,a^{2}+29 B \,b^{2}\right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{15 d}-\frac {\left (4 a^{2} A -16 A a b +5 A \,b^{2}-8 B \,a^{2}+10 B a b -8 B \,b^{2}\right ) \left (\tan ^{9}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{4 d}+\frac {\left (4 a^{2} A +16 A a b +5 A \,b^{2}+8 B \,a^{2}+10 B a b +8 B \,b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{4 d}-\frac {\left (12 a^{2} A -64 A a b +3 A \,b^{2}-32 B \,a^{2}+6 B a b -16 B \,b^{2}\right ) \left (\tan ^{7}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{6 d}+\frac {\left (12 a^{2} A +64 A a b +3 A \,b^{2}+32 B \,a^{2}+6 B a b +16 B \,b^{2}\right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{6 d}}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{5}}\) | \(429\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.29, size = 176, normalized size = 0.93 \begin {gather*} \frac {120 \, {\left (2 \, d x + 2 \, c + \sin \left (2 \, d x + 2 \, c\right )\right )} A a^{2} - 160 \, {\left (\sin \left (d x + c\right )^{3} - 3 \, \sin \left (d x + c\right )\right )} B a^{2} - 320 \, {\left (\sin \left (d x + c\right )^{3} - 3 \, \sin \left (d x + c\right )\right )} A a b + 30 \, {\left (12 \, d x + 12 \, c + \sin \left (4 \, d x + 4 \, c\right ) + 8 \, \sin \left (2 \, d x + 2 \, c\right )\right )} B a b + 15 \, {\left (12 \, d x + 12 \, c + \sin \left (4 \, d x + 4 \, c\right ) + 8 \, \sin \left (2 \, d x + 2 \, c\right )\right )} A b^{2} + 32 \, {\left (3 \, \sin \left (d x + c\right )^{5} - 10 \, \sin \left (d x + c\right )^{3} + 15 \, \sin \left (d x + c\right )\right )} B b^{2}}{480 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.37, size = 142, normalized size = 0.75 \begin {gather*} \frac {15 \, {\left (4 \, A a^{2} + 6 \, B a b + 3 \, A b^{2}\right )} d x + {\left (24 \, B b^{2} \cos \left (d x + c\right )^{4} + 30 \, {\left (2 \, B a b + A b^{2}\right )} \cos \left (d x + c\right )^{3} + 80 \, B a^{2} + 160 \, A a b + 64 \, B b^{2} + 8 \, {\left (5 \, B a^{2} + 10 \, A a b + 4 \, B b^{2}\right )} \cos \left (d x + c\right )^{2} + 15 \, {\left (4 \, A a^{2} + 6 \, B a b + 3 \, A b^{2}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{120 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 459 vs.
\(2 (184) = 368\).
time = 0.36, size = 459, normalized size = 2.43 \begin {gather*} \begin {cases} \frac {A a^{2} x \sin ^{2}{\left (c + d x \right )}}{2} + \frac {A a^{2} x \cos ^{2}{\left (c + d x \right )}}{2} + \frac {A a^{2} \sin {\left (c + d x \right )} \cos {\left (c + d x \right )}}{2 d} + \frac {4 A a b \sin ^{3}{\left (c + d x \right )}}{3 d} + \frac {2 A a b \sin {\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{d} + \frac {3 A b^{2} x \sin ^{4}{\left (c + d x \right )}}{8} + \frac {3 A b^{2} x \sin ^{2}{\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{4} + \frac {3 A b^{2} x \cos ^{4}{\left (c + d x \right )}}{8} + \frac {3 A b^{2} \sin ^{3}{\left (c + d x \right )} \cos {\left (c + d x \right )}}{8 d} + \frac {5 A b^{2} \sin {\left (c + d x \right )} \cos ^{3}{\left (c + d x \right )}}{8 d} + \frac {2 B a^{2} \sin ^{3}{\left (c + d x \right )}}{3 d} + \frac {B a^{2} \sin {\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{d} + \frac {3 B a b x \sin ^{4}{\left (c + d x \right )}}{4} + \frac {3 B a b x \sin ^{2}{\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{2} + \frac {3 B a b x \cos ^{4}{\left (c + d x \right )}}{4} + \frac {3 B a b \sin ^{3}{\left (c + d x \right )} \cos {\left (c + d x \right )}}{4 d} + \frac {5 B a b \sin {\left (c + d x \right )} \cos ^{3}{\left (c + d x \right )}}{4 d} + \frac {8 B b^{2} \sin ^{5}{\left (c + d x \right )}}{15 d} + \frac {4 B b^{2} \sin ^{3}{\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{3 d} + \frac {B b^{2} \sin {\left (c + d x \right )} \cos ^{4}{\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (A + B \cos {\left (c \right )}\right ) \left (a + b \cos {\left (c \right )}\right )^{2} \cos ^{2}{\left (c \right )} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.46, size = 156, normalized size = 0.83 \begin {gather*} \frac {B b^{2} \sin \left (5 \, d x + 5 \, c\right )}{80 \, d} + \frac {1}{8} \, {\left (4 \, A a^{2} + 6 \, B a b + 3 \, A b^{2}\right )} x + \frac {{\left (2 \, B a b + A b^{2}\right )} \sin \left (4 \, d x + 4 \, c\right )}{32 \, d} + \frac {{\left (4 \, B a^{2} + 8 \, A a b + 5 \, B b^{2}\right )} \sin \left (3 \, d x + 3 \, c\right )}{48 \, d} + \frac {{\left (A a^{2} + 2 \, B a b + A b^{2}\right )} \sin \left (2 \, d x + 2 \, c\right )}{4 \, d} + \frac {{\left (6 \, B a^{2} + 12 \, A a b + 5 \, B b^{2}\right )} \sin \left (d x + c\right )}{8 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 3.93, size = 307, normalized size = 1.62 \begin {gather*} \frac {x\,\left (A\,a^2+\frac {3\,B\,a\,b}{2}+\frac {3\,A\,b^2}{4}\right )}{2}+\frac {\left (2\,B\,a^2-\frac {5\,A\,b^2}{4}-A\,a^2+2\,B\,b^2+4\,A\,a\,b-\frac {5\,B\,a\,b}{2}\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^9+\left (\frac {16\,B\,a^2}{3}-\frac {A\,b^2}{2}-2\,A\,a^2+\frac {8\,B\,b^2}{3}+\frac {32\,A\,a\,b}{3}-B\,a\,b\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^7+\left (\frac {20\,B\,a^2}{3}+\frac {40\,A\,a\,b}{3}+\frac {116\,B\,b^2}{15}\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5+\left (2\,A\,a^2+\frac {A\,b^2}{2}+\frac {16\,B\,a^2}{3}+\frac {8\,B\,b^2}{3}+\frac {32\,A\,a\,b}{3}+B\,a\,b\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3+\left (A\,a^2+\frac {5\,A\,b^2}{4}+2\,B\,a^2+2\,B\,b^2+4\,A\,a\,b+\frac {5\,B\,a\,b}{2}\right )\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^{10}+5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^8+10\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+10\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4+5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________